package com.six.exception;

import com.six.util.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.nio.file.AccessDeniedException;

@RestControllerAdvice
public class GlobalExceptionHandler {

    // 403 权限不足
    @ExceptionHandler(AccessDeniedException.class)
    public Result<Void> handle(AccessDeniedException e) {
        return Result.fail(403, e.getMessage());
    }

    // 500 兜底
    @ExceptionHandler(Exception.class)
    public Result<Void> handle(Exception e) {
        return Result.fail(e.getMessage());
    }
}